#include <ZExt.h>
#include <fstream>
#include <assert.h>
void ZExtFile(){
	ZExt ze2;
	ze2.initDeflate();
	fstream fi("..\\x64\\Debug\\s.txt",ios::in);
	fstream fo("..\\x64\\Debug\\d.txt",ios::out|ios::binary);
	assert(fi.is_open());
	ze2.ostream(&fo);
	ze2.deflat(&fi);
	fi.close();
	fo.close();
	cout<<"------------"<<endl;
	ZExt ze;
	ze.initInflate();
	fstream fi2("..\\x64\\Debug\\d.txt",ios::in|ios::binary);
	fstream fo2("..\\x64\\Debug\\ds.txt",ios::out);
	ze.ostream(&fo2);
	ze.inflat(&fi2);
	fi2.close();
	fo2.close();
}
void ZExtChar(){
	ZExt ze2;
	ze2.initDeflate(Z_DEFAULT_COMPRESSION);
	ze2.deflat("sdfsdkfsfsdfsdl\n",Z_NO_FLUSH);
	ze2.deflat("aaaaaaaaaaaaa\n",Z_NO_FLUSH);
	ze2.deflat("acacacacacacacac");
	cout<<"------------"<<endl;
	unsigned char buf[ZEXT_CHUNK]={0};
	ze2.buf.read((char*)buf,ZEXT_CHUNK);
	ZExt ze;
	ze.initInflate();
	ze.inflat(buf,ze2.buf.gcount());
	cout<<ze.bufStr()<<endl;
}
int main(int argc,char** argv){
	//ZExtFile();
	ZExtChar();
	getchar();
	return 0;
}